import socket, sys

#Initialize the socket
clientSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#Get host and port
host = sys.argv[1]
port = 0
#Get the server's port, 2000 by default
if len(sys.argv) == 2:
    port = 2000
else:
    port = int(sys.argv[2])

#Connect to the server
clientSocket.connect((host,port))

while True:
    data = clientSocket.recv(1024)
    prompt = False
    if data[0] == 'p':
        prompt = True
    print (data[1:])
    if prompt:
        clientSocket.send(raw_input() + " ")